<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#assign currentMenu="systemInform"/>
    <#include "../common/header.ftl">
    <script src="/js/plugins/jquery-bootstrap/jquery.bootstrap.min.js"></script>
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/ckeditor/ckeditor.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <style type="text/css">
        .modal-body {
            max-height: 750px;
            overflow-y: auto;
        }

        .modal-body img {
            width: 100%;
        }
    </style>

</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">系统通知管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/systemInform/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入相关内容">
                </div>
                <a role="button" class="btn btn-success btn-default releaseBtn">
                    <span class="glyphicon glyphicon-share"></span> 发布
                </a>
                <button id="btn_query" class="btn btn-default">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>序号</th>
                    <th>通知内容</th>
                    <th>发布时间</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.content}</td>
                        <td>${entity.releaseTime?string("yyyy-MM-dd")}</td>

                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>

<div id="inputModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemInform/release.do" method="post"
                      id="editForm">
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">通知内容：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="content"/>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">发布时间：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="releaseTime"
                                   onclick="WdatePicker({readOnly:true,maxDate:new Date()})"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        //给发布按钮个拒绝按钮绑定点击事件，因为同属于改变游记状态的事件，可以绑在一起
        $(".releaseBtn").click(function () {
            $("#inputModal").modal("show");
        })

        $(".submitBtn").click(function () {
            $.messager.confirm("温馨提示", "请确保发布内容无误,确定提交吗?", function () {
                //发送异步请求保存通知
               $("#editForm").ajaxSubmit(function (data) {
                   if(data.success){
                       window.location.reload();
                   }else{
                       alert(data.msg);
                   }
               })
            })
        })
    })
</script>
</body>
</html>